<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8"/>
	<meta name="keywords" content="find,replace,replacement,regex,regular expression"/>
	<link rel="stylesheet" href="../../Shared/sty/standard.css"/>
	<script defer src="../../Shared/js/toc.js"></script>
	
	<title>Find or replace text in CotEditor on Mac</title>
</head>

<body>
<a name="howto_find"></a>

<h1>Find or replace text in CotEditor on Mac</h1>

<p>CotEditor has a powerful find and replacement feature that also can use regular expression.</p>

<p>In the CotEditor app <img class="appicon" srcset="../../Shared/gfx/icon_32x32@2x.png 2x" alt=""/> on your Mac, choose Find &gt; Find to show the Find window.</p>

<figure>
	<img srcset="../gfx/findpanel@2x.png 2x" alt="Screenshot of the Find window"/>
</figure>


<section>
<h2>Enter find or replace conditions</h2>

<h3>Find/Replacement Fields</h3>
<p>Enter the text to find to the find field, the field with a lope icon.</p>

<p>To replace matched text, enter the text to replace with to the replacement field, the field with a pen icon in addition to the search text. When the replacement field is empty by replacement, the matched text is just removed.</p>

<p>To insert the following special characters to the fields, use the following key combinations:</p>

<table>
	<thead>
		<tr><th>Character</th><th>Key combination</th></tr>
	</thead>
	
	<tbody>
		<tr><td>line ending character</td><td><kbd>Option</kbd>-<kbd>Return</kbd></td></tr>
		<tr><td>tab character</td><td><kbd>Option</kbd>-<kbd>Tab</kbd></td></tr>
	</tbody>
</table>


<h3>Find/Replacement Histories</h3>

<p>You can reuse previous find/replacement text by selecting them from the lope/pen icon in the field.</p>


<h3>Find Options</h3>

<table>
	<thead>
		<tr><th>Option</th><th>Description</th></tr>
	</thead>
	<tbody>
		<tr><td>Regular Expression</td><td>Search with regular expression.</td></tr>
		<tr><td>Ignore Case</td><td>Ignore character case on search.</td></tr>
		<tr><td>In Selection</td><td>Search text only from selection.</td></tr>
	</tbody>
</table>
</section>


<section>
<h2>Change advanced find options</h2>

<p>You can customize the find behavior in the advanced find options view. To open the view, click the gear button in the Find window.</p>

<table>
	<thead>
		<tr><th>Option</th><th>Description</th></tr>
	</thead>
	<tbody>
		<tr><td>Wrap search around</td><td>Find from the the beginning of the document if there is no match after the insertion point.</td></tr>
		<tr><td>Search incrementally</td><td>Search document as you type in the search field.</td></tr>
	</tbody>
</table>


<h3>Textual Search</h3>
<p>Options for search when the regular expression is turned off.</p>

<table>
	<thead>
		<tr><th>Option</th><th>Description</th><th>Default</th></tr>
	</thead>
	<tbody>
		<tr><td>Match only whole words</td><td>Restrict search results to whole words.</td><td>Off</td></tr>
		<tr><td>Distinguish characters strictly</td><td>Exact character-by-character equivalence.</td><td>Off</td></tr>
		<tr><td>Ignore diacritical marks</td><td>Search ignores diacritical marks (for example, ö = o).</td><td>Off</td></tr>
		<tr><td>Ignore width differences</td><td>Search ignores width differences in character forms (for example, ａ = a).</td><td>Off</td></tr>
	</tbody>
</table>


<h3>Regular Expression Search</h3>
<p>Options for search when the regular expression is selected.</p>

<table>
	<thead>
		<tr><th>Option</th><th>Description</th><th>Default</th></tr>
	</thead>
	<tbody>
		<tr><td>Dot matches line separators</td><td>Allow . to match any character, including newline characters (singleline).</td><td>Off</td></tr>
		<tr><td>Anchors match lines</td><td>Allow ^ and $ to match the start and end of lines (multiline).</td><td>On</td></tr>
		<tr><td>Use Unicode word boundaries</td><td>Use Unicode TR#29 to specify word boundaries</td><td>Off</td></tr>
		<tr><td>Unescape replacement text</td><td>Unescape metacharacters with backslash in the replacement text.</td><td>On</td></tr>
	</tbody>
</table>
</section>


<section>
<h2>Highlight search results</h2>

<p>With the Find All and Highlight All commands, all the places in the document that match your search criteria can be highlighted. When searching using regular expressions, each captured group is highlighted in a different color.</p>
</p>To remove the highlight, choose Find &gt; Remove Highlights.</p>
</section>


<section id="cf">
<h2>See also</h2>
<ul>
	<li><a href="howto_find_newline.html">Find or replace a line ending in CotEditor on Mac</a></li>
	<li><a href="about_regex.html">Use the regular expression in CotEditor on Mac</a></li>
	<li><a href="howto_multiple_replace.html">Replace text by multiple rules in CotEditor on Mac</a></li>
</ul>
</section>

</body>
</html>
